﻿/**
 *	(C) 2014 Yuanjj
 *
 * 	define bridge object
 *
 *	histroy
 * 		2014-06-25	yuanjj	- create the file
 */

#ifndef _HTML_BRIGDE_
#define	_HTML_BRIGDE_

//#include "html5applicationviewer.h"
#include "../mainwindow.h"
#include "../../typedef.h"

#define		MIN_WIDTH	960
#define		MIN_HEIGHT	720

class cls_bridge : public MainWindow
{
    Q_OBJECT

public:
    explicit cls_bridge( MainWindow* parent = NULL );
    ~cls_bridge();

protected slots:
    // when javascript window object has been created
    void populateJavaScriptWindowObject();

    // slot for js
protected slots:
    /**********************************************************
     *	user data
     **********************************************************/
    /**
     *	user login
     */
    void user_login( QString account, QString passwd );

    /**********************************************************
     * host data
     **********************************************************/
    /**
     *	load host
     */
    void load_host();

    /**********************************************************
     *	tunnel data
     **********************************************************/
    /** load tunnel type */
    void load_tunnel_type();

    /** load tunnel */
    void load_tunnel();

    /** update tunnel */
    void update_tunnel( QString name, QString type, QString number, QString host, QString remark, QString used );

    /** delete tunnel */
    void delete_tunnel( QString number );

    /**********************************************************
     *	device data
     **********************************************************/
    /**
     *	load device type
     */
    void load_device_type();

    /**
     *	load protocal
     */
    void load_protocal();

    /**
     *	load device
     */
    void load_device();

    /**
     *	update device
     */
    void update_device( QString param );
    /*
                        QString dev_id, QString dev_type, QString dev_name, QString dev_pos,
                        QString machine, QString tunnel_num, QString pto_name, QString pto_file,
                        QString host, QString value, QString x, QString y, QString setup );
                        */

    /**********************************************************
     *	alarm data
     **********************************************************/
    /**
     *	load alarm
     */
    void load_alarm();

    /**********************************************************
     *	event data
     **********************************************************/
    /**
     *	load event type
     */
    void load_event_type();

    /**
     *	load event
     */
    void load_event();

    /**********************************************************
     *	scene data
     **********************************************************/
    /**
     *	load scene
     */
    void load_scene();

    /**
     * save scene
     */
    void save_scene( QString scene, QString receipt );

    /**
     *	load frame
     */
    void load_frame();

    /**********************************************************
     *	sync call
     **********************************************************/
    /**
     *	open file select dialog
     */
    void file_select( QString cmp_id );

    // slot for c++
protected slots:
    /**
     *	call js function
     */
    void on_call_js( QString );

protected:
    pem_void_t resizeEvent( QResizeEvent * event );

public:
    /**
     *	initialize the bridge object
     */
    pem_error_t 	instance();

    /**
     *	add a qt object into js with another namespace name
     */
    pem_void_t 		set_javascript_object( QString name, QObject* obj );

    /**
     *	init the window size
     */
    pem_void_t 		init_window_size( pem_s32_t width, pem_s32_t height );

    /**
     *	call javascript routine
     */
    pem_void_t		call_js_routine( QString& js_fun );

};

#endif	// _HTML_BRIGDE_
